/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package processes;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import javax.swing.JScrollBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;

/**
 *
 * @author lucmussi
 */
public class StreamGobbler extends Thread
{
    InputStream is;
    JTextArea txtCon;
    JScrollPane scrollCon;

    public StreamGobbler(InputStream is, JTextArea txtCon, JScrollPane scrollCon)
    {
        this.is = is;
        this.txtCon = txtCon;
        this.scrollCon = scrollCon;
    }

    @Override
    public void run()
    {
        try
        {
            InputStreamReader isr = new InputStreamReader(is);
            BufferedReader br = new BufferedReader(isr);
            String line=null;
            while ( (line = br.readLine()) != null){
                txtCon.append(line+"\n");
            }

            } catch (IOException ioe)
              {
                ioe.printStackTrace();
              }
    }
}
